package handler

import (
	"github.com/gin-gonic/gin"
	"user_admin/global"
	"user_admin/internal/request"
	"user_admin/models"
)

func InfoFind(c *gin.Context) {
	var info request.InfoBoardFind
	if err := c.ShouldBind(&info); err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "获取失败",
			"data": nil,
		})
		return
	}

	var infos models.InfoBoard
	err := global.DB.Debug().Where("uid=?", info.Uid).Find(&infos).Error

	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "查询失败",
			"data": nil,
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "查询成功",
		"data": infos.Title,
	})
}
